<html>
<head><meta charset="utf-8"><title>What is &quot;attribute privacy&quot;? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html">What is &quot;attribute privacy&quot;?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236393421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236393421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236393421">(Apr 27 2021 at 19:19)</a>:</h4>
<blockquote>
<p>When attribute privacy is implemented, <code>Path</code> should be annotated as <code>#[repr(transparent)]</code>.</p>
</blockquote>
<p>— <a href="https://github.com/rust-lang/rust/blob/1.51.0/library/std/src/path.rs#L1726">docs for <code>Path</code></a></p>



<a name="236393643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236393643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236393643">(Apr 27 2021 at 19:20)</a>:</h4>
<p>looks like it's from <a href="https://github.com/rust-lang/rust/pull/61969">https://github.com/rust-lang/rust/pull/61969</a> but the rationale seems a bit iffy</p>



<a name="236393675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236393675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236393675">(Apr 27 2021 at 19:20)</a>:</h4>
<p>of course the standard library can rely on implementation details!</p>



<a name="236393954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236393954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236393954">(Apr 27 2021 at 19:22)</a>:</h4>
<p>Ah, <a href="https://github.com/rust-lang/rust/pull/61969#issuecomment-504784204">this comment</a> provides context:</p>
<blockquote>
<p>marking (public) types repr(transparent) is a commitment that we may not (in the case of CStr, definitely do not) want to make</p>
</blockquote>



<a name="236394083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236394083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236394083">(Apr 27 2021 at 19:23)</a>:</h4>
<p>That's why we have avoided putting the attribute and a hypothetical "attribute privacy" would allow adding the attribute but not expose it publicly.</p>



<a name="236394088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236394088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236394088">(Apr 27 2021 at 19:23)</a>:</h4>
<p>Thanks!</p>



<a name="236395758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236395758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236395758">(Apr 27 2021 at 19:36)</a>:</h4>
<p>The implementation is still private, so without a documentation is is rather unclear if <code>#[repr(transparent)]</code> would be a commitment of any kind.</p>



<a name="236395862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236395862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236395862">(Apr 27 2021 at 19:36)</a>:</h4>
<p>With any luck the safe transmute work will help clarify things here, as it'll start exposing traits that are more obviously a promise (rather than just an implementation detail).</p>



<a name="236405046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236405046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236405046">(Apr 27 2021 at 20:46)</a>:</h4>
<p><span class="user-mention silent" data-user-id="352985">tm</span> <a href="#narrow/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F/near/236395758">said</a>:</p>
<blockquote>
<p>The implementation is still private, so without a documentation is is rather unclear if <code>#[repr(transparent)]</code> would be a commitment of any kind.</p>
</blockquote>
<p>I'm not following your point. <code>repr(transparent)</code> is shown in the docs:</p>
<p><a href="/user_uploads/4715/jRY8gwSIXD9L3HO-ilt8dbnJ/image.png">image.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/jRY8gwSIXD9L3HO-ilt8dbnJ/image.png" title="image.png"><img src="/user_uploads/4715/jRY8gwSIXD9L3HO-ilt8dbnJ/image.png"></a></div><p>That seems to make it a public commitment.</p>



<a name="236405284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236405284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236405284">(Apr 27 2021 at 20:47)</a>:</h4>
<p>I think that, in the specific case of <code>Path</code>, we <em>don't</em> want to make a public guarantee that it's transmutable to anything. I don't quite know <em>why</em>, but that seems to be the gist of the thread <strong>Steven Fackler</strong> linked.</p>



<a name="236405493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236405493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236405493">(Apr 27 2021 at 20:49)</a>:</h4>
<p><code>Path</code> doesn't have any public fields so someone looking at the docs wouldn't know if there aren't secretly like 20 non-ZST fields anyway.</p>



<a name="236405594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236405594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236405594">(Apr 27 2021 at 20:50)</a>:</h4>
<p>In other words it is known that the type has a transparent layout, but not what leaks through the transparent layout.</p>



<a name="236407647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236407647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236407647">(Apr 27 2021 at 21:01)</a>:</h4>
<p>And I guess for <code>MaybeUninit</code>, it's generic over <code>T</code>, so it's "obvious" what's in there.</p>



<a name="236407867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236407867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236407867">(Apr 27 2021 at 21:02)</a>:</h4>
<blockquote>
<p>if there aren't secretly like 20 non-ZST fields anyway.</p>
</blockquote>
<p>Wouldn't they have to be 20 ZST fields, otherwise it couldn't be transparent to start with?</p>



<a name="236409672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/What%20is%20%22attribute%20privacy%22%3F/near/236409672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/What.20is.20.22attribute.20privacy.22.3F.html#236409672">(Apr 27 2021 at 21:09)</a>:</h4>
<p>Like bjorn3 mentions, my point was that type of field could be arbitrary (including some kind of a wrapper type), and one has to examine the source code to find out what it is.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>